-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tackle Typing and Linting Errors #379
Open
gileshd
wants to merge
27
commits into
main
Choose a base branch
from
ghd/typing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gileshd
force-pushed
the
ghd/typing
branch
8 times, most recently
from
September 24, 2024 15:20
27008b7
to
47fe33f
Compare
This stops type-checkers worrying about escape-sequences.
- Rename to PRNGKeyT to differentiate from `jax.random` function - Change type to Array - see https://jax.readthedocs.io/en/latest/jep/9263-typed-keys.html#type-annotations-for-prng-keys
- Change default arguments to floats in `monotonically_increasing` function - Help type-checkers parse `compute_state_overlap` function - Update `keepdims` default value in `pytree_sum` to match `jnp.sum`
- Change attributes of these protocols to read-only. - This change means that instances of `NamedTuple` are compatible with these protocols - Add runtime_checkable decorator to Protocols - This allows the Protocolcs to be checked by runtime type checkers such as beartype which can be used to verify jaxtyping annotations
Major changes: - Fix an error in `_compute_all_transition_probs` which caused the return array to be too short. - The `filtered_probs` were being truncated twice instead of once. - Replace `jaxtyping.Int` with `dynamax.typing.IntScalar` or `int` - this reflects when integer scalar arrays are accepted - `jaxtyping.[Dtype]` cannot be used directly for type checking instead they must be used as part of an array. - Fix the shape of `transition_matrix`: - if transition_matrix has a leading timestep axis it should be of length T-1 not of length T. - Add annotation indicating that `transition_matrix` is an optional argument - Raise ValueError when neither `transition_matrix` or `transition_fn` provided.
Further, enforce that either key or initial_probs specified to initialize method.
Further, enforce that either key or initial_probs specified in initialize method.
- Add annotations to the *GaussianHMMEmssions classes - Apply some small formatting changes to reduce line length in places
- Add annotations to the *GaussianMixtureHMMEmssions classes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR is an initial step in an overhaul of the type annotations in the code base.
Details
The aim of the PR is to:
Further updates to other parts of the codebase will come in subsequent PRs.
Discussion
The state of PRNGKey typing in this PR is a bit inconsistent
dynamax.types.PRNGKeyT
(which is an alias forjaxtyping.Array
) and sometimes directly asjaxtyping.Array
.There are a lot of commmits here! After review we can perhaps squash many of the HMM typing commits into appropriate groups.
Commit Overview
This is a brief categorisation of the commits in this PR: